package com.nowcoder.community.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Data
//index必须为lowercase不然会报错 index:类似mysql中的数据库,type:类似mysql中的表,shards:分片(将数据分成几片),replicas:副本(3份)
@Document(indexName = "discusspost", type = "_doc", shards = 6, replicas = 3)
public class DiscussPost {

    /**
     * 自增主键,插入数据后将自增主键设置到对象中
     */
    @TableId(type = IdType.AUTO)
    @Id
    private Integer id;

    @Field(type = FieldType.Integer)
    private Integer userId;

    //文本类型,将对应的内容拆分成最多的词,搜索时搜索最常见的分词即可
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String title;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String content;

    //0-普通; 1-置顶;
    @Field(type = FieldType.Integer)
    private Integer type;

    //0-正常; 1-精华; 2-拉黑;
    @Field(type = FieldType.Integer)
    private Integer status;

    @Field(type = FieldType.Date)
    private Date createTime;

    @Field(type = FieldType.Integer)
    private Integer commentCount;

    @Field(type = FieldType.Double)
    private Double score;

}
